<template>
  <div>
     <div class="config">
       <div class="back" onclick="window.history.go(-1)"><img src="../assets/images/back.png" alt=""></div>
        <p>邀请码</p>
    </div>
     <div class="box">
           <p>1.先关注镜面集团公众号</p>
           <p>2.复制以下邀请码去公众号进行注册</p>
           <p class="code">{{code}}</p>
           <p class="code">{{level}}</p>
           

     </div>
  </div>
</template>

<script>
export default {
    name: "inviteCode",
    data() {
        return {
            level: "",
            higher_up: "",
            code: ""
        };
    },
    methods: {},
    beforeCreate() {
        document.getElementsByTagName("body")[0].style.background = "#5aa0c8";
    },
    mounted() {
   
        // 获取分享链接里的等级跟uid
        var obj = window.location.href;
        if (obj.lastIndexOf("?") != -1) {
            var index = obj.lastIndexOf("?");
            obj = obj.substring(index + 1, obj.length);
            this.level = obj.slice(6, 7);
            this.higher_up = obj.slice(18);
            console.log(this.higher_up)
        }
        if (this.level == "" && this.higher_up == "") {
            this.$Message.warning("邀请码已经失效");
        } else {
            console.log(this.higher_up)
            var qs = require("qs");
            this.axios({
                method: "post",
                url: `${this.siteUrl}/getEncodeMessage`,
                data: qs.stringify({
                    higher_up: this.higher_up,
                    level: this.level
                })
            })
            .then(response => {
                
                if ((response.data.result == 200)) {
                    this.code = response.data.data;
                } else {
                    alert("请求失败");
                }
            })
            .catch(function(error) {
                console.log(error);
            });
        }
      
    }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
p {
    font-size: 18px;
    line-height: 50px;
    margin-left: 10px;
}
.code {
    font-size: 16px;
}
</style>
